import 'dart:async';

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:hongsheng/model/SPClassNoticesNotice.dart';
import 'package:hongsheng/utils/SPClassCommonMethods.dart';
import 'package:hongsheng/utils/SPClassImageUtil.dart';
import 'package:flutter_swiper_null_safety/flutter_swiper_null_safety.dart';

class SPClassNoticeWidget extends StatefulWidget {
  List<SPClassNoticesNotice> ?notices=[];
  SPClassNoticeWidget({Key? key,this.notices}) : super(key: key);

  @override
  State<SPClassNoticeWidget> createState() => _SPClassNoticeWidgetState();
}

class _SPClassNoticeWidgetState extends State<SPClassNoticeWidget> {
  @override
  void initState() {
    // TODO: implement initState
    super.initState();

  }
  @override
  Widget build(BuildContext context) {
    return widget.notices!.isNotEmpty? Container(
      alignment: Alignment.center,
      padding: EdgeInsets.only(left: width(14),right: width(5)),
      decoration: BoxDecoration(
          color: Colors.black45,
          borderRadius: BorderRadius.vertical(top:Radius.circular(width(15)) )
      ),
      height: width(25),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.center,
        crossAxisAlignment: CrossAxisAlignment.center,
        children: [
          Image.asset(SPClassImageUtil.spFunGetImagePath("ic_home_msg"),width: width(27),),
          SizedBox(width: 5,),
          Expanded(child: Container(
            height: width(25),
            child: Swiper(
              scrollDirection:Axis.vertical,autoplay: true,
              itemCount: widget.notices!.length,
              itemBuilder: (BuildContext context, int index) {
                return  Row(
                  children: <Widget>[

                    Container(
                      alignment: Alignment.center,
                      height: width(25),
                      child:  Container(
                        margin: EdgeInsets.only(left: width(5)),
                        alignment: Alignment.centerLeft,
                        height: width(25),
                        child: Text(widget.notices![index].title??'',style: TextStyle(color: Colors.white,fontSize: sp(12)),maxLines: 1,overflow: TextOverflow.ellipsis,),
                      ),
                    )
                  ],
                );
              },),
          )),
        ],
      ),
    ) :SizedBox();
  }

  @override
  void dispose() {
    // TODO: implement dispose
    super.dispose();

  }
}
